package com.yygo.webapp.controller;

import com.yygo.service.LoanProductManager;
import org.appfuse.dao.SearchException;
import org.appfuse.service.GenericManager;
import com.yygo.model.LoanProduct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;

@Controller
@RequestMapping("/loanProducts*")
public class LoanProductController {
    private LoanProductManager loanProductManager;

    @Autowired
    public void setLoanProductManager(LoanProductManager loanProductManager) {
        this.loanProductManager = loanProductManager;
    }

    @RequestMapping(method = RequestMethod.GET)
    public Model handleRequest()
    throws Exception {
        Model model = new ExtendedModelMap();
        Collection<LoanProduct> result = new LinkedHashSet<LoanProduct>(loanProductManager.getAll(false));
        model.addAttribute(new ArrayList<LoanProduct>(result));
        return model;
    }
}
